package ioc

import (
	"github.com/spf13/viper"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	commentv1 "jk-time/webook/api/proto/gen/comment/v1"
)

func InitCommentClient() commentv1.CommentSerivceClient {
	type Config struct {
		Addr string `yaml:"addr"`
	}
	var config Config
	err := viper.UnmarshalKey("grpc.client.comment", &config)
	if err != nil {
		panic(err)
	}

	cc, err := grpc.NewClient(config.Addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		panic(err)
	}

	return commentv1.NewCommentSerivceClient(cc)
}
